Skip to content

fix(runtime): send oversized pi prompts on stdin - #1167

Closed
REI-330 wants to merge 1 commit into
Tencent:mainfrom
REI-330:fix/pi-prompt-stdin
Closed

REI-330 wants to merge 1 commit into
Tencent:mainfrom
REI-330:fix/pi-prompt-stdin

Conversation

@REI-330

@REI-330 REI-330 commented Nov 21, 2026

Copy link
Copy Markdown

Problem

With the pi executor, a chat turn that embeds the whole conversation appends the prompt as the last argv argument. Once the prompt grows past Linux MAX_ARG_STRLEN (128KiB), fork/exec fails with argument list too long before pi starts, so every later message in that conversation fails.

internal/runtime/provider_agentcli.go built the pi argv with argv = append(append(argv, extra...), prompt) unconditionally. Short turns are fine; long chat histories are not.

Change

  • Send an oversized pi prompt through CommandSpec.Stdin and omit the positional argument. pi reads the prompt from stdin when the positional argument is omitted, and Stdin is already forwarded by local, Docker (-i) and conversation execution, so the launch contract is unchanged.
  • The threshold reuses maxArgvPromptBytes (96KiB), which leaves 32KiB of headroom under MAX_ARG_STRLEN; short turns keep the existing positional form.
  • Added TestPiOversizedPromptGoesToStdin, which checks that no argv entry exceeds the limit, that stdin carries the exact prompt, and that a short turn still uses the positional argument.

Other agent-CLI branches were left untouched: only pi is documented to read the prompt from stdin when the positional argument is omitted.

Validation

  • GOOS=linux go vet ./internal/runtime/ — clean.
  • GOOS=linux go test -c ./internal/runtime/ — compiles.
  • Ran that test binary in a Linux environment: runtime.test -test.run 'TestPiOversizedPromptGoesToStdin|TestPromptOnStdin|TestAgentCLICommandChatRestrictions' -test.v — all pass.
  • The full ./internal/runtime suite was also run in the same sandbox; the only failures there are environment-only (git/python3 are not installed in that sandbox), and they are unrelated to this change. CI provides both tools.

Fixes #1081.

The pi provider appended the whole prompt to argv. A chat prompt embeds the
conversation history and can grow past Linux MAX_ARG_STRLEN, so fork/exec
failed with E2BIG ("argument list too long") before the CLI started. Pi reads
the prompt from stdin when the positional argument is omitted, so route an
oversized prompt through CommandSpec.Stdin and keep short turns on argv.
@REI-330

REI-330 commented Nov 21, 2026

Copy link
Copy Markdown
Author

Superseded by #1115, which already implements this fix; closing to avoid duplicate work.

@REI-330 REI-330 closed this Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: pi provider 长对话触发 E2BIG(argument list too long),CLI 无法启动

1 participant